#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int x=0,sign=1;
    char c;
    c=getchar();
    while(c>'9'||c<'0')
    {
        if(c=='-') sign=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=x*10+(c-'0');
        c=getchar();
    }
    return x*sign;
}
const int N=1e5+5;
struct Node{
    int d,v,a,st,ed;
    bool die,cao;
};Node car[N];
int der[N];
int useful[N];
int n,m,L,V,ans1=0,ans2=0,ear;
int search(int pl)
{
    int l=1,r=m,mid;
    while(l<r)
    {
        mid=(l+r)/2;
        if(der[mid]==pl) return mid;
        if(der[mid]>pl) r=mid;
        else l=mid+1;
    }
    return r;
}
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T,tot;
    bool adv,adj;
    T=read();
    while(T--)
    {
        ans1=0,ans2=0,ear=1e6+5,tot=0;
        memset(useful,0,sizeof(useful));
        n=read();
        m=read();
        L=read();
        V=read();
        for(int i=1;i<=n;i++)
        {
            car[i].d=read();
            car[i].v=read();
            car[i].a=read();
            car[i].die=1;
            car[i].cao=0;
        }
        for(int i=1;i<=m;i++)
        {
            der[i]=read();
        }
        int j;
        double vt;
        for(int i=1;i<=n;i++)
        {
            adv=0,adj=0;
            j=search(car[i].d);
            if(car[i].a>=0)
            {
                if(car[i].v>V&&car[i].d<=der[m])
                {
                    car[i].cao=1;
                    car[i].st=j;
                    car[i].ed=n;
                    continue;
                }
                if(car[i].a==0) continue;
            }
            if(car[i].a<0&&car[i].v<V) continue;
            for(;j<=m;j++)
            {
                if((car[i].v*car[i].v+2*car[i].a*(der[j]-car[i].d))<=0&&adv)
                {
                    car[i].ed=j-1;
                    adj=1;
                    break;
                }
                else if((car[i].v*car[i].v+2*car[i].a*(der[j]-car[i].d))<=0) break;
                vt=sqrt(car[i].v*car[i].v+2*car[i].a*(der[j]-car[i].d));
                if(vt>V&&!adv)
                {
                    adv=1;
                    car[i].cao=1;
                    car[i].st=j;
                }
                if(vt<=V&&adv)
                {
                    car[i].ed=j-1;
                    adj=1;
                    break;
                }
            }
            if(!adj) car[i].ed=m;
        }
        ans1=0;
        for(int i=1;i<=n;i++)
        {
            if(car[i].cao==1)
            {
                for(int j=car[i].st;j<=car[i].ed;j++)
                {
                    useful[j]++;
                    tot++;
                }
                ans1++;
            }

        }
        int maxn,shan;
        while(tot>0)
        {
            maxn=-114514;
            for(int i=1;i<=m;i++)
            {
                if(maxn<=useful[i])
                {
                    shan=i;
                    maxn=useful[i];
                }
            }
            for(int i=1;i<=n;i++)
            {
                if(car[i].cao==1)
                {
                    if(shan>=car[i].st&&shan<=car[i].ed&&car[i].die)
                    {
                        for(int j=car[i].st;j<=car[i].ed;j++)
                        {
                            tot--;
                            useful[j]--;
                        }
                        car[i].die=0;
                    }
                }
            }
            ans2++;
        }
        cout<<ans1<<" "<<m-ans2<<endl;
    }

    return 0;
}
